package day09.callback;

public class Match {
	public static void match(Player p1, Player p2) {
		int p1Count = 0;
		int p2Count = 0;
		String p1Name = p1.getName();
		String p2Name = p2.getName();
		for (int i = 1; i <= 100; i++) {
			System.out.print("Round " + i + ":\t");
			String p1Show = p1.show();
			String p2Show = p2.show();
			System.out.print(p1Name + ":" + p1Show + "--" + p2Name + ":"
					+ p2Show + "\t");
			boolean b1 = p1Show.equals(Player.SHITOU)
					&& p2Show.equals(Player.JIANDAO);
			boolean b2 = p1Show.equals(Player.JIANDAO)
					&& p2Show.equals(Player.BU);
			boolean b3 = p1Show.equals(Player.BU)
					&& p2Show.equals(Player.SHITOU);
			if (b1 || b2 || b3) {
				p1Count++;
				System.out.println(p1Name + " ʤ");
			} else if (!(p1Show.equals(p2Show))) {
				p2Count++;
				System.out.println(p2Name + " ʤ");
			} else {
				System.out.println("ƽ");
			}
		}
		if (p1Count > p2Count) {
			System.out.println(p1Count + ":" + p2Count + " " + p1Name + "ʤ");
		} else if (p1Count < p2Count) {
			System.out.println(p1Count + ":" + p2Count + " " + p2Name + "ʤ");
		} else {
			System.out.println(p1Count + ":" + p2Count + " ƽ");
		}
	}

}
